cmake_minimum_required(VERSION 3.10)
project(paddlespeech_tts_cpp)


# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(ABSL_PROPAGATE_CXX_STD ON)


# 设置pkgconfig路径
set(ENV{PKG_CONFIG_PATH} "${CMAKE_SOURCE_DIR}/third-party/build/lib/pkgconfig")
find_package(PkgConfig REQUIRED)

# 寻找依赖
pkg_check_modules(ABSL   REQUIRED absl_strings IMPORTED_TARGET)
pkg_check_modules(GFLAGS REQUIRED gflags       IMPORTED_TARGET)
pkg_check_modules(GLOG   REQUIRED libglog      IMPORTED_TARGET)

# 包含头文件目录
include_directories(
    ${CMAKE_SOURCE_DIR}/third-party/build/src/cppjieba/include
    ${CMAKE_SOURCE_DIR}/third-party/build/src/limonp/include
)

# 引入线程库
find_package(Threads REQUIRED)

include_directories(src)

file(GLOB FRONT_SOURCES
    ./src/base/*.cpp
    ./src/front/*.cpp
)

# 生成共享库
add_library(paddlespeech_tts SHARED ${FRONT_SOURCES})
# 链接库
target_link_libraries(
    paddlespeech_tts
    PUBLIC
    PkgConfig::GFLAGS
    PkgConfig::GLOG
    PkgConfig::ABSL
    Threads::Threads
)

#file(GLOB FRONT_DEMO_SOURCES front_demo/*.cpp)
#add_executable(tts_front_demo ${FRONT_DEMO_SOURCES})

#target_include_directories(tts_front_demo PUBLIC ./front_demo)
#target_link_libraries(tts_front_demo PUBLIC paddlespeech_tts)


# 设置Android NDK相关的编译选项
# 你需要根据你的NDK版本和目标平台进行相应的调整
#set(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a")
set(CMAKE_ANDROID_NDK /home/jiazh/android/sdk/ndk)
set(CMAKE_ANDROID_NDK_VERSION "23.1.7779620")
set(CMAKE_ANDROID_STL_TYPE "c++_shared")
# openmp
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fopenmp")

find_library(
    log-lib
    log
)

find_library(
    android-lib
    android
)

target_link_libraries(
    paddlespeech_tts
    PUBLIC
    android
    ${log-lib}
    ${android-lib}
)